package top.codedance.iotp.server.net.handle.subhandle.controller.http.sync;

import com.alibaba.fastjson.JSONObject;
import top.codedance.iotp.common.entity.UserEntity;
import top.codedance.iotp.server.ServerApplication;
import top.codedance.iotp.server.net.handle.subhandle.controller.AdapterController;
import top.codedance.iotp.server.net.handle.util.UserService;
import org.apache.log4j.Logger;

import java.util.List;

public class UserListController extends AdapterController {

    private static Logger logger = ServerApplication.getLogger(UserListController.class);

    public String doSubHandler(JSONObject body) {
        try {
            if (!adminVerification()) {
                return response403("No access");
            }
            List<UserEntity> list = UserService.list();
            return okResponse(list);
        } catch (Exception e) {
            return response500("Programe exception");
        }
    }
}
